package cn.tedu.boot40.controller;

import cn.tedu.boot40.entity.User;
import cn.tedu.boot40.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname: UserController
 * @Author: bromide
 * @CreateTime: 2022/5/13--9:11
 * @Version: V1.0
 * @Description:
 */
@RestController
public class UserController {
    @Autowired(required = false)
    UserMapper mapper;

    @RequestMapping("/reg")
    public int reg(@RequestBody User user){
        if (mapper.selectByName(user.getUsername())==null){
            //如果是空则说明是没有该用户  可以注册
            mapper.insert(user);
            return 1;
        }else {
            return 2;
        }
    }
}
